package com.yang.webapi.module.controller;

import com.yang.service.model.dto.post.ShopPostDTO;
import com.yang.service.model.vo.ShopVO;
import com.yang.webapi.module.service.ShopWebService;
import com.zhy.base.qiniu.QiNiuToken;
import com.zhy.base.service.page.PageResult;
import com.zhy.base.webapi.annoation.ResponseFormatter;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiModelProperty;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.validation.Valid;

/**
 * Created by xin7k
 * Date: 2019/12/4 0004
 */
@Slf4j
@ResponseFormatter
@RestController
@RequestMapping("shop")
@Api(tags = "店铺模块", description = "ShopController")
public class ShopController {
    @Autowired
    private ShopWebService shopWebService;

    @ApiOperation("新增一个店铺")
    @PostMapping
    public String save(@RequestBody @Valid ShopPostDTO dto) {
        return shopWebService.save(dto);
    }

    /**
     * 如果要加入接口道白名单
     * 那么久不能使用path参数
     * 因为白名单的url是固定死的
     *
     * @param number
     * @return
     */
    @ApiOperation("获取指定数量的优选店铺")
    @GetMapping("priority")
    public PageResult<ShopVO> getPriorityShop(@RequestParam(value = "number") Integer number){
        return shopWebService.getPriorityShop(number);

    }

    @ApiOperation("根据ShopId获取店铺信息")
    @GetMapping("shopId")
    public ShopVO getShopByShopId(@RequestParam(value = "shopId") String shopId){
        return shopWebService.getShopByShopId(shopId);
    }


}
